﻿Imports System.Data.SqlClient

Public Class clsCLASIFICACIONES
    Public Function GUARDAR_CLASIFICACION(ByVal ID_CATALOGO As Integer, ByVal NUM_CLASIF As Integer, ByVal CODIGO As String, ByVal NOMBRE As String, ByVal ESTATUS As Integer) As Integer
        Dim cnConn As New SqlConnection
        cnConn.ConnectionString = CitraConnection

        Dim Command As New SqlCommand("sp_CLASIFICACIONES_INSERTAR", cnConn)
        Command.CommandType = CommandType.StoredProcedure

        Command.Parameters.Add(New SqlParameter("@NUM_CATALOGO", SqlDbType.Int))
        Command.Parameters("@NUM_CATALOGO").Value = ID_CATALOGO
        Command.Parameters.Add(New SqlParameter("@NUM_CLASIFICACION", SqlDbType.Int))
        Command.Parameters("@NUM_CLASIFICACION").Value = NUM_CLASIF
        Command.Parameters.Add(New SqlParameter("@CODIGO", SqlDbType.VarChar, 200))
        Command.Parameters("@CODIGO").Value = CODIGO
        Command.Parameters.Add(New SqlParameter("@NOMBRE", SqlDbType.VarChar, 100))
        Command.Parameters("@NOMBRE").Value = NOMBRE
        Command.Parameters.Add(New SqlParameter("@ESTATUS", SqlDbType.Int))
        Command.Parameters("@ESTATUS").Value = ESTATUS
        Command.Parameters.Add(New SqlParameter("@NOMBRE_USUARIO", SqlDbType.VarChar, 200))
        Command.Parameters("@NOMBRE_USUARIO").Value = UsuarioActivo

        Dim Lector As SqlDataReader
        Try
            cnConn.Open()

            Lector = Command.ExecuteReader
            If Lector.Read() Then
                GUARDAR_CLASIFICACION = Lector("RESULTADO")
                cnConn.Close()
            Else
                If cnConn.State = ConnectionState.Open Then
                    cnConn.Close()
                End If
            End If
        Catch ex As Exception
            GUARDAR_CLASIFICACION = -1
            MsgBox(ex.Message, MsgBoxStyle.Information, "Aviso")
            If cnConn.State = ConnectionState.Open Then
                cnConn.Close()
            End If
        End Try


    End Function
End Class
